package com.kitty.game.player;

import com.github.benmanes.caffeine.cache.Caffeine;
import com.google.common.cache.CacheBuilder;
import org.springframework.boot.autoconfigure.cache.CacheProperties;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;

import org.springframework.cache.caffeine.CaffeineCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
public class GuavaCacheConfig {
    @Bean
    public CacheManager cacheManager() {
        CaffeineCacheManager cacheManager = new CaffeineCacheManager();
        Caffeine<Object, Object> caffeine = Caffeine.newBuilder().expireAfterAccess(30, TimeUnit.MINUTES).maximumSize(8000);
//        cacheManager.setCacheBuilder(
//                CacheBuilder.newBuilder().
//                        expireAfterAccess(30, TimeUnit.MINUTES).
//                        maximumSize(8000));
//        cacheManager.setCaffeine();.
        cacheManager.setCaffeine(caffeine);
        return cacheManager;
    }
}